<template>
  <transition name="fade">
    <div class="toast-container" v-if="this.$store.state.Toast">
      <p class="txt-t">注销确认</p>
      <p class="txt-m">该操作将注销此账号，是否确认？</p>
      <div class="btn-two">
        <a href="javascript:;" class="no" @click="closeToast">取消</a>
        <a href="javascript:;" class="yes" @click="logOutLogin">确认</a>
      </div>
    </div>
  </transition>
</template>
<script>
import { deleteUserApi } from '@/logrequest/api'
export default {
  data() {
    return {}
  },
  methods: {
    closeToast() {
      this.$store.commit('closeToast')
    },
    logOutLogin() {
      const id = localStorage.getItem('uid')
      deleteUserApi(id).then(({ data: res }) => {
        if (res.status === 200) {
          this.$store.commit('openTitle', '注销成功')
          this.$store.dispatch('ToggleTitle')
          this.$router.push('/loginPage')
          this.$store.commit('closeToast')
          // localStorage.clear()
        } else {
          this.$store.commit('openTitle', res.message)
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.toast-container {
  background-color: #fff;
  position: fixed;
  width: 75vw;
  height: 20vh;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  margin: auto;
  border-radius: 10px;
  overflow: hidden;
  padding-top: 15px;
  box-sizing: border-box;
  box-shadow: 0px 0px 10px #ccc;
  p {
    text-align: center;
    line-height: 40px;
  }
  .txt-m {
    color: #000;
    font-size: 13px;
  }
  .btn-two {
    position: absolute;
    bottom: 0;
    width: 100%;
    a {
      width: 50%;
      display: inline-block;
      text-align: center;
      color: #000;
      text-decoration: none;
      padding: 10px 0;
      border-top: 1px solid #ccc;
      box-sizing: border-box;
    }
    .yes {
      color: red;
      border-left: 1px solid #ccc;
    }
  }
}
</style>